package com.qiall.boot.util.controller;

import com.qiall.Base64Util;
import com.qiall.FreeMarkParserUtil;
import com.qiall.JdbcTemplateParseUtil;
import com.qiall.boot.util.entity.RequestEntity;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/dataParse")
public class StringParseUtilController {

    @PostMapping("markDown")
    public String getFreeMarkData(@RequestBody RequestEntity request){
       String text= Base64Util.decode(request.getData());
       return new   FreeMarkParserUtil().parse(text,request.getParams());
    }

    @PostMapping("jdbcTemplate")
    public String jdbcTemplate(@RequestBody RequestEntity request){
        return new JdbcTemplateParseUtil().parse(request.getData(),request.getParams());
    }

    @PostMapping("markDownAndJdbcTemplate")
    public String markDownAndJdbcTemplate(@RequestBody RequestEntity request){
        String text= Base64Util.decode(request.getData());
        FreeMarkParserUtil  markParserUtil= new  FreeMarkParserUtil();
        String markDown=markParserUtil.parse(text,request.getParams());
      return   new JdbcTemplateParseUtil().parse(markDown,request.getParams());
    }

}
